<template>
	<view class="mainpadding" v-if="pageShow">
		<view class="" >
			<!-- 酒店订单 -->
			<view class="ffffff mainpadding radius" v-if="data_type==1">
				<view class="ershiba zhonghei fonweight">订单编号：{{dataAll.order_no}}</view>
				<view class="flexbetween margin_top ">
					<image class="sptp" :src="dataAll.hoteltype.image_text" mode=""></image>
					<view class="flexcolumnbet" style="width: 77%;height: 124rpx;">
						<view class="ershiba xiaohei yhxk">{{dataAll.hoteltype.name}}</view>
						<view class="flexbetween margin_top1" style="width: 100%;">
							<view class="titletext xiaohong fonweight">¥{{dataAll.open_price}}</view>
							<view class="ershil xiaocheng">x{{dataAll.people_num}}</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 商品订单 -->
			<view class="ffffff mainpadding radius" v-if="data_type==2">
				<view class="ershiba zhonghei fonweight">订单编号：{{dataAll.order_no}}</view>
				<view class="flexbetween margin_top " v-for="item in dataAll.goods" :key="item.id">
					<image class="sptp" :src="item.image_text" mode=""></image>
					<view class="flexcolumnbet" style="width: 77%;height: 124rpx;">
						<view class="ershiba xiaohei yhxk">{{item.title}}</view>
						<view class="flexbetween margin_top1" style="width: 100%;">
							<view class="titletext xiaohong fonweight">¥{{item.actual_payment}}</view>
							<view class="ershil xiaocheng">x{{item.number}}</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 发票 -->
			<view class="ffffff mainpadding radius margin_top">
				<view class="ershiba zhonghei fonweight">发票类型</view>
				<view class="flexleft margin_top">
					<view class="margin_right3" :class="fp_type==1?'yxzbtn':'wxzbtn'" @click="fp_type=1">电子发票</view>
					<view :class="fp_type==2?'yxzbtn':'wxzbtn'" @click="fp_type=2">增值税专用发票</view>
				</view>
				
			</view>
			<!-- 抬头类型 -->
			<view class="ffffff mainpadding radius">
				<view class="ershiba zhonghei fonweight">抬头类型</view>
				<view class="flexleft margin_top">
					<view class="margin_right3" :class="tt_type==1?'yxzbtn':'wxzbtn'" @click="tt_type=1">个人</view>
					<view :class="tt_type==2?'yxzbtn':'wxzbtn'" @click="tt_type=2">单位</view>
				</view>
			</view>
			<!--发票抬头  -->
			<view class="ffffff mainpadding radius margin_top flexbetween" @click="selectttfn(tt_type)">
				<view class="ershiba zhonghei fonweight">发票抬头</view>
				<view class="flexright">
					<view class="ershiba xiaocheng margin_right1">{{ttname}}</view>
					<u-icon name="arrow-right" color="#999999"></u-icon>
				</view>
			</view>
		</view>
		<view class="gudingdb ffffff mainpadding">
			<view class="bigbtn" @click="submit()">提交</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				data_type:1,//1酒店，2商品
				fp_type:1,//
				tt_type: 1,
				listid:"",
				user_tt_id:"",
				ttname:"",
				dataAll:{},
				pageShow:false
			}
		},
		onLoad(options) {
			uni.$on("selecttt",data=>{
				this.user_tt_id = data.id
				this.ttname = data.name
			})
			this.data_type = options.data_type
			this.listid = options.id
			this.getDetail()
		},
		onUnload() {
			this.$off('selecttt')
		},
		methods: {
			selectttfn(tt_type){
				uni.navigateTo({
					url:"/pages_wode/wodefapiaott?tt_type="+tt_type
				})
			},
			getDetail(){
				let url = "/api/order/goodsOrderFpSure"
				if(this.data_type==1){
					url = "/api/hotelordercl/hotelOrderFpSure"
				}
				httpRequest.request(url, 'GET', {
					id: this.listid
				}, false, false, true).then(res => {
					this.dataAll = res.data
					this.pageShow = true
				})
			},
			submit() {
				if(this.user_tt_id==""){
					httpRequest.toast("请选择发票抬头")
					return false
				}
				let url = '/api/hotelordercl/applyUserFp'
				let data = {
					tt_type: this.tt_type,
					data_type: this.data_type,
					data_id: this.listid,
					user_tt_id: this.user_tt_id,
					fp_type: this.fp_type,
				}
				uni.showLoading({
					mask:true,
					title:"请稍后"
				})
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					uni.hideLoading()
					httpRequest.toast(res.msg)
					if(res.code==1){
						setTimeout(()=>{
							uni.navigateBack(1)
						},1000)
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.wxzbtn {
		font-size: 24rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		background: #f0f0f0;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		border: 2rpx solid #f0f0f0;
		color: #666666;
		padding: 17rpx 20rpx;
	}

	.yxzbtn {
		font-size: 24rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		background: rgba(255, 147, 65, 0.1);
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		border: 2rpx solid #FF9341;
		color: #FF9341;
		padding: 17rpx 20rpx;
	}

	.sptp {
		width: 124rpx;
		min-width: 124rpx;
		height: 124rpx;
		border-radius: 14rpx 14rpx 14rpx 14rpx;
	}
</style>